package com.info;

public class BonusInfo {
	
	public static final BonusInfo NO_BONUS = new BonusInfo();

	private int[] bonus;
	
	public BonusInfo(){
		bonus = new int[BonusEnum.values().length];
		
		for (int i = 0; i < bonus.length; i++){
			bonus[i] = 0;
		}
	}
	public void addBonus(BonusEnum bonusType, int amount, int multiple){
		if (bonusType.getIsStackable()){
			bonus[bonusType.ordinal()] += amount * multiple;
		}else{
			bonus[bonusType.ordinal()] = Math.max(bonus[bonusType.ordinal()], amount * multiple);
		}
	}
	
	public void addBonus(BonusEnum bonusType, int amount){
		this.addBonus(bonusType, amount, 1);
	}
	
	public void addBonus(BonusInfo info){
		for (BonusEnum e : BonusEnum.values()){
			this.addBonus(e, info.bonus[e.ordinal()]);
		}
	}
	
	public void addBonus(BonusInfo info, int multiple){
		for (BonusEnum e : BonusEnum.values()){
			this.addBonus(e, info.bonus[e.ordinal()], multiple);
		}
	}
	public int[] getBonusBreakdown(){
		return bonus;
	}
	
	public int getBonusTotal(){
		int total = 0;
		for (int i = 0; i < bonus.length; i++){
			total += bonus[i];
		}
		return total;
	}
}
